package com.alex.wechat.mp.util;

import me.chanjar.weixin.common.util.crypto.SHA1;

/**
 * 请求校验工具类
 * 
 * @author Debenson
 * @since 0.1
 */
public class SignUtil {

  /**
   * 验证签名
   * 
   * @param signature
   * @param timestamp
   * @param nonce
   * @return
   */
  public static boolean checkSignature(String token, String signature, String timestamp,
      String nonce) {
    try {
      return SHA1.gen(token, timestamp, nonce).equals(signature);
    } catch (Exception e) {
      return false;
    }
  }

}
